from bs4 import BeautifulSoup
import requests



# url = 'https://imip.midea.com/main.html#/p/workbench'
# response = requests.get(url)
# soup = BeautifulSoup(response.text, 'html.parser')
# print(soup)
# # soup 写入到一个html文件中
# with open('soup.html', 'w', encoding='utf-8') as f:
#     f.write(str(soup))


# 登录 URL
login_url = 'https://signin.midea.com/login?service=http%3A%2F%2Fdevsecops.midea.com%2Fsystem'

# 登录表单数据
data = {
    'username': 'ex_yejing1',
    'password': 'MKS@1818'
}

# 发送 POST 请求模拟登录
response = requests.post(login_url, data=data)

# 获取 cookie 并存储在会话中
cookie = response.cookies

print(cookie)

# 使用 cookie 访问需要登录的网页
response = requests.get('https://devsecops.midea.com/system', cookies=cookie)
# 打印网页内容
print(response.text)
with open('soup.html', 'w', encoding='utf-8') as f:
    f.write(str(response.text))